]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
MessageTray: pass keyboard events to tray icons
authorGiovanni Campagna <gcampagna@src.gnome.org>
Fri, 2 Nov 2012 15:09:04 +0000 (16:09 +0100)
committerGiovanni Campagna <gcampagna@src.gnome.org>
Fri, 18 Jan 2013 19:53:20 +0000 (20:53 +0100)
Synthetize XKeyEvents for clicks emulated by StButton using Return or
Space.

https://bugzilla.gnome.org/show_bug.cgi?id=687425

js/ui/keyboard.js
js/ui/messageTray.js
js/ui/notificationDaemon.js
src/shell-tray-icon.c

index 7ce21d2193793272a70414948896420e65013651..c60649d50a61bef2b83ff75a292036ce41de357a 100644 (file)
@@ -637,11 +637,7 @@ const KeyboardSource = new Lang.Class({
         this.keepTrayOnSummaryClick = true;
     },
 
-    handleSummaryClick: function() {
-        let event = Clutter.get_current_event();
-        if (event.type() != Clutter.EventType.BUTTON_RELEASE)
-            return false;
-
+    handleSummaryClick: function(button) {
         this.open();
         return true;
     },
index 246bbf653e344afdc846e5c296c2a35f2234795e..9e408ff684d2931a37faa4ad5235018e144620ee 100644 (file)
@@ -1831,7 +1831,7 @@ const MessageTray = new Lang.Class({
     },
 
     _onSummaryItemClicked: function(summaryItem, button) {
-        if (summaryItem.source.handleSummaryClick()) {
+        if (summaryItem.source.handleSummaryClick(button)) {
             if (summaryItem.source.keepTrayOnSummaryClick)
                 this._setClickedSummaryItem(null);
             else
index ba0c06a96215e7f02029d7371beb02002282b43f..f23b268b31feedd5f2e76ff4ab2e4e58d9b08099 100644 (file)
@@ -565,19 +565,17 @@ const Source = new Lang.Class({
             this.notify(notification);
     },
 
-    handleSummaryClick: function() {
+    handleSummaryClick: function(button) {
         if (!this.trayIcon)
             return false;
 
         let event = Clutter.get_current_event();
-        if (event.type() != Clutter.EventType.BUTTON_RELEASE)
-            return false;
 
         // Left clicks are passed through only where there aren't unacknowledged
         // notifications, so it possible to open them in summary mode; right
         // clicks are always forwarded, as the right click menu is not useful for
         // tray icons
-        if (event.get_button() == 1 &&
+        if (button == 1 &&
             this.notifications.length > 0)
             return false;
 
index 08bffa8b7709460ac43af33e693e3afadd2bd797..15b4e34fc2dda2ffd080c7c7892d2760880daaeb 100644 (file)
@@ -180,6 +180,7 @@ void
 shell_tray_icon_click (ShellTrayIcon *icon,
                        ClutterEvent  *event)
 {
+  XKeyEvent xkevent;
   XButtonEvent xbevent;
   XCrossingEvent xcevent;
   GdkWindow *remote_window;
@@ -187,8 +188,10 @@ shell_tray_icon_click (ShellTrayIcon *icon,
   int x_root, y_root;
   Display *xdisplay;
   Window xwindow, xrootwindow;
+  ClutterEventType event_type = clutter_event_type (event);
 
-  g_return_if_fail (clutter_event_type (event) == CLUTTER_BUTTON_RELEASE);
+  g_return_if_fail (event_type == CLUTTER_BUTTON_RELEASE ||
+                    event_type == CLUTTER_KEY_RELEASE);
 
   gdk_error_trap_push ();
 
@@ -215,22 +218,44 @@ shell_tray_icon_click (ShellTrayIcon *icon,
   XSendEvent (xdisplay, xwindow, False, 0, (XEvent *)&xcevent);
 
   /* Now do the click */
-  xbevent.type = ButtonPress;
-  xbevent.window = xwindow;
-  xbevent.root = xrootwindow;
-  xbevent.subwindow = None;
-  xbevent.time = xcevent.time;
-  xbevent.x = xcevent.x;
-  xbevent.y = xcevent.y;
-  xbevent.x_root = xcevent.x_root;
-  xbevent.y_root = xcevent.y_root;
-  xbevent.state = clutter_event_get_state (event);
-  xbevent.button = clutter_event_get_button (event);
-  xbevent.same_screen = True;
-  XSendEvent (xdisplay, xwindow, False, 0, (XEvent *)&xbevent);
-
-  xbevent.type = ButtonRelease;
-  XSendEvent (xdisplay, xwindow, False, 0, (XEvent *)&xbevent);
+  if (event_type == CLUTTER_BUTTON_RELEASE)
+    {
+      xbevent.window = xwindow;
+      xbevent.root = xrootwindow;
+      xbevent.subwindow = None;
+      xbevent.time = xcevent.time;
+      xbevent.x = xcevent.x;
+      xbevent.y = xcevent.y;
+      xbevent.x_root = xcevent.x_root;
+      xbevent.y_root = xcevent.y_root;
+      xbevent.state = clutter_event_get_state (event);
+      xbevent.same_screen = True;
+      xbevent.type = ButtonPress;
+      xbevent.button = clutter_event_get_button (event);
+      XSendEvent (xdisplay, xwindow, False, 0, (XEvent *)&xbevent);
+
+      xbevent.type = ButtonRelease;
+      XSendEvent (xdisplay, xwindow, False, 0, (XEvent *)&xbevent);
+    }
+  else
+    {
+      xkevent.window = xwindow;
+      xkevent.root = xrootwindow;
+      xkevent.subwindow = None;
+      xkevent.time = xcevent.time;
+      xkevent.x = xcevent.x;
+      xkevent.y = xcevent.y;
+      xkevent.x_root = xcevent.x_root;
+      xkevent.y_root = xcevent.y_root;
+      xkevent.state = clutter_event_get_state (event);
+      xkevent.same_screen = True;
+      xkevent.type = KeyPress;
+      xkevent.keycode = clutter_event_get_key_code (event);
+      XSendEvent (xdisplay, xwindow, False, 0, (XEvent *)&xkevent);
+
+      xkevent.type = KeyRelease;
+      XSendEvent (xdisplay, xwindow, False, 0, (XEvent *)&xkevent);
+    }
 
   /* And move the pointer back out */
   xcevent.type = LeaveNotify;